#include"UDPServer.hpp"
#include<memory>
#include"Dict.hpp"

std::string handler(const std::string&str)
{
    std::string s="hello ";
    s+=str;
    return s;
}

//   ./UDPServer.cc  ip port
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        LOG(LogLevel::FATAL)<<"Usage: ip port";
        exit(1);
    }
    uint16_t port=std::stoi(argv[1]);
    //std::string ip((char*)argv[1]);

    Dict dict;
    dict.DictLoad();

    std::unique_ptr sv=std::make_unique<UDPServer>(port,[&dict](const std::string&word)->std::string{
        return dict.Translate(word);
    });
    
    sv->Init();
    sv->Start();
    return 0;
}